<template>
  <el-form-item
    :label="labelRuleValue.title"
    :prop="propValue"
    :rules="
      requirsd(labelRuleValue.type)
        ? [
            {
              required: labelRuleValue.rule == 'required' ? true : false,
              message: labelRuleValue.title + $t('common.common33'),
              trigger: 'blur',
            },
            {
              pattern: evalreg(labelRuleValue.preg),
              message: labelRuleValue.return_msg,
              trigger: 'blur',
            },
          ]
        : null
    "
  >
    <el-input
      :disabled="disabledValue"
      :type="inputType"
      :autosize="{ minRows: 4 }"
      :show-password="showPass"
      :value="value"
      clearable
      @input="handleValue"
    ></el-input>
  </el-form-item>
</template>
<script>
export default {
  name: "textTag",
  props: {
    inputType: {
      type: String, //input 框类型
      default: "text",
    },
    showPass: {
      type: Boolean,
      default: false,
    },
    value: {
      type: [String, Number], //对应值
      default: "",
    },
    propValue: {
      type: String,
      default: "",
    },
    labelRuleValue: {
      type: Object,
      default: function () {
        return {};
      },
    },
    disabledValue: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    evalreg(val) {
      val = val || "";
      return eval(val);
    },
    requirsd(type) {
      return !["array", "json"].includes(type);
    },
    handleValue(val) {
      this.$emit("update:value", val);
    },
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>